import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDDropChoose {
	/**编号(主键)*/
	id,
	/**备注*/
	desc,
	/**chooseid*/
	chooseid,
	/**物品类型--1.资源点2.道具3.装备4.符文5.魔纹*/
	itemType,
	/**装备等级*/
	equipmentLevel,
	/**物品id*/
	itemid,
	/**数量*/
	num,
	/**是否需要消息播报*/
	messageMark,

	/**枚举数量*/
	EnumCount
}



export class CDDropChoose{
	/**编号(主键)*/
	public id: number;
	/**备注*/
	public desc: string;
	/**chooseid*/
	public chooseid: number;
	/**物品类型--1.资源点2.道具3.装备4.符文5.魔纹*/
	public itemType: number;
	/**装备等级*/
	public equipmentLevel: number;
	/**物品id*/
	public itemid: number;
	/**数量*/
	public num: number;
	/**是否需要消息播报*/
	public messageMark: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDDropChoose.id: return this.id;
			case E_CDDropChoose.desc: return this.desc;
			case E_CDDropChoose.chooseid: return this.chooseid;
			case E_CDDropChoose.itemType: return this.itemType;
			case E_CDDropChoose.equipmentLevel: return this.equipmentLevel;
			case E_CDDropChoose.itemid: return this.itemid;
			case E_CDDropChoose.num: return this.num;
			case E_CDDropChoose.messageMark: return this.messageMark;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDDropChoose.id: this.id = v; break;
			case E_CDDropChoose.desc: this.desc = v; break;
			case E_CDDropChoose.chooseid: this.chooseid = v; break;
			case E_CDDropChoose.itemType: this.itemType = v; break;
			case E_CDDropChoose.equipmentLevel: this.equipmentLevel = v; break;
			case E_CDDropChoose.itemid: this.itemid = v; break;
			case E_CDDropChoose.num: this.num = v; break;
			case E_CDDropChoose.messageMark: this.messageMark = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDDropChoose> = new HashMap<number, CDDropChoose>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDDropChoose[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDDropChoose();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].chooseid = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].itemType = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].equipmentLevel = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].itemid = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].num = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].messageMark = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDDropChoose{
		return this.datas ? this.datas.get(id) : null;
	}
}
